package com.plug.service;

import com.plug.entity.PlugCompareTask;
import com.plug.repository.PlugCompareTaskMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by slayes on 2017/1/12.
 */
@Service("plugCompareTaskService")
public class PlugCompareTaskServiceImpl implements IPlugCompareTaskService {

    @Resource
    PlugCompareTaskMapper plugCompareTaskMapper;

    @Override
    public int save(PlugCompareTask plugCompareTask) {
        if(plugCompareTask != null){
            if(plugCompareTask.getId() == null){
                return plugCompareTaskMapper.insertSelective(plugCompareTask);
            } else {
                return plugCompareTaskMapper.updateByPrimaryKeySelective(plugCompareTask);
            }
        } else {
            return -1;
        }
    }

    public int deleteBatch(List<Integer> list){
        return plugCompareTaskMapper.deleteBatch(list);
    }

    /**
     * 查询所有的备份任务配置信息
     * @return
     */
    public List<PlugCompareTask> findAll() {
        return plugCompareTaskMapper.findAll();
    }

    public int delete(Integer id) {
        return plugCompareTaskMapper.deleteByPrimaryKey(id);
    }

    public int findTotal() {
        return plugCompareTaskMapper.findTotal();
    }

    public List<Map<String,Object>> findPages(Integer offset, Integer limit) {
        return plugCompareTaskMapper.findPages(offset, limit);
    }
}
